package exam;

import java.io.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;

import java.net.*;

public class ChatGUI {
	   public JTextArea chatSend_Hex;
	   public JTextArea chatSend_Decimal;
	   public JTextArea chatSend_Ascii;
	   public JTextArea chatReceive_Hex;
	   public JTextArea chatReceive_Decimal;
	   public JTextArea chatReceive_Ascii;
	   public JScrollPane sp_send_Hex;
	   public JScrollPane sp_send_Decimal;
	   public JScrollPane sp_send_Ascii;
	   public JScrollPane sp_receive_Hex;
	   public JScrollPane sp_receive_Decimal;
	   public JScrollPane sp_receive_Ascii;
	   public JPanel panel;
	   public JPanel mainPane;
	   public JTabbedPane tabPanel1;
	   public JTabbedPane tabPanel2;
	   public JPanel UpPanel;
	   public JPanel DownPanel;
	   ListGUI lg;
	   
	   public ChatGUI(){
	      tabPanel1 = new JTabbedPane();
	      tabPanel2 = new JTabbedPane();
	      UpPanel = new JPanel(new BorderLayout());
	      DownPanel = new JPanel(new BorderLayout());
	      String s;
	      JLabel lb1 = new JLabel("Send Window");
	      JLabel lb2 = new JLabel("Receive Window");
	      lb1.setHorizontalAlignment(SwingConstants.CENTER);
	      lb2.setHorizontalAlignment(SwingConstants.CENTER);
	      
	      tabPanel1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
	      tabPanel2.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
	  
	      chatSend_Hex = new JTextArea(15, 35);
	      chatSend_Hex.setEditable(false);
	      chatSend_Hex.setForeground(Color.blue);
	      chatSend_Hex.setLineWrap(true);
	      sp_send_Hex = new JScrollPane(chatSend_Hex,
	            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
	            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	      
//	      s = TCPTester.stringToHex(chatSend.getText());
//	      chatSend.append(s);

	      chatReceive_Hex = new JTextArea(15, 35);
	      chatReceive_Hex.setEditable(false);
	      chatReceive_Hex.setLineWrap(true);
	      chatReceive_Hex.setForeground(Color.green);
	      sp_receive_Hex = new JScrollPane(chatReceive_Hex,
	            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
	            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	      
/*	      s = TCPTester.stringToHex(chatReceive.getText());
	      chatReceive.append(s);	      
*/
	      tabPanel1.addTab("Hex", sp_send_Hex);
	      tabPanel2.addTab("Hex", sp_receive_Hex);
	      
	      chatSend_Decimal = new JTextArea(15, 35);
	      chatSend_Decimal.setEditable(false);
	      chatSend_Decimal.setForeground(Color.blue);
	      chatSend_Decimal.setLineWrap(true);
	      sp_send_Decimal = new JScrollPane(chatSend_Decimal,
	            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
	            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	      
//	      s = TCPTester.stringToDecimal(chatSend.getText());
//	      chatSend.append(s);
	      
	      chatReceive_Decimal = new JTextArea(15, 35);
	      chatReceive_Decimal.setEditable(false);
	      chatReceive_Decimal.setLineWrap(true);
	      chatReceive_Decimal.setForeground(Color.green);
	      sp_receive_Decimal = new JScrollPane(chatReceive_Decimal,
	            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
	            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	      
//	      s = TCPTester.stringToDecimal(chatReceive.getText());
//	      chatReceive.append(s);
	      
	      tabPanel1.addTab("Desimal", sp_send_Decimal);
	      tabPanel2.addTab("Desimal", sp_receive_Decimal);
	      
	      chatSend_Ascii = new JTextArea(15, 35);
	      chatSend_Ascii.setEditable(false);
	      chatSend_Ascii.setForeground(Color.blue);
	      chatSend_Ascii.setLineWrap(true);
	      sp_send_Ascii = new JScrollPane(chatSend_Ascii,
	            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
	            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

//	      s = TCPTester.stringToASCII(chatSend_Ascii.getText());
//	      chatSend_Ascii.append(s);
	      
	      chatReceive_Ascii = new JTextArea(15, 35);
	      chatReceive_Ascii.setEditable(false);
	      chatReceive_Ascii.setLineWrap(true);
	      chatReceive_Ascii.setForeground(Color.green);
	      sp_receive_Ascii = new JScrollPane(chatReceive_Ascii,
	            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
	            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

/*	      s = TCPTester.stringToASCII(chatReceive.getText());
	      chatReceive.append(s);
*/	      
	      tabPanel1.addTab("ASCII", sp_send_Ascii);   
	      tabPanel2.addTab("ASCII", sp_receive_Ascii);
	      tabPanel1.setSelectedIndex(2);
	      tabPanel2.setSelectedIndex(2);

	      UpPanel.add(lb1,"North");
	      UpPanel.add(tabPanel1,"Center");
	      DownPanel.add(lb2,"North");
	      DownPanel.add(tabPanel2,"Center");
	      panel = new JPanel(new BorderLayout());
	      panel.add(UpPanel,"North");
	      panel.add(DownPanel,"South");
	      
//	      int row = lg.row;
//	      s = String.valueOf(lg.table.getValueAt(row, 1));
//	      chatSend_Ascii.append(s);
	   }
	
	public static void main(String[] args){
		new ChatGUI();
	}
}
